
import 'dart:html' as html;

class HTMLOpen {
  static void open(String url, {String? name = '_blank',String? options}) {
    html.window.open(
      url,
      name??'_blank', // '_blank' 表示新标签页，'_new' 表示新窗口
      options,//'width=800,height=600,resizable=yes,scrollbars=yes'
    );
  }

  ///  打开路由
  static openRoute(String route, {String? name = '_blank', String? options}) {
    final currentUrl = html.window.location.href;
    final newUrl = Uri.parse(currentUrl).replace(path: route).toString();
    open(newUrl,name: name, options: options);
  }

  /// 打开本地文件
  static  openFile(String path, {String? name = '_blank', String? options}) {
    final localUrl = Uri.file(path).toString();
    open(localUrl,name: name, options: options);
  }
}